<template>
	<view>
		<nav-header title="" :showRight="false"></nav-header>
		<view class="user-info">
			<view class="head">
				<head-image :name="userInfo.nickName" :url="userInfo.headImage" :size="100"></head-image>
				<view class="right">
					<text>{{ userInfo.nickName }}</text>
					<view class="num-item">
						<text>友号：{{ userInfo.userFriendId }}</text>
						<button type="primary" size="mini" @click="copy1">复制</button>
					</view>
					<view class="num-item">
						<text>商号：{{ userInfo.userBusinessId }}</text>
						<button type="primary" size="mini" @click="copy2">复制</button>
					</view>
				</view>
			</view>
			<view>
				<img :src="getResource('/icon/code.svg')" alt="" class="code-img" />
			</view>
			<view class="sub-title">
				<text>扫一扫上面的二维码图案，加我为朋友</text>
			</view>
			<view class="share">
				<view class="share-item" @click="upload">
					<img :src="getResource('/icon/upload.svg')" alt="" class="share-img">
					<text>保存</text>
				</view>
				<view class="share-item" @click="share">
					<img :src="getResource('/icon/share.svg')" alt="" class="share-img">
					<text>分享</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {

		}
	},
	methods: {
		copy1() {
			let text = this.userInfo.userFriendId

			uni.setClipboardData({
				data: text.toString(),
				success: function (res) {
					console.log('复制的信息1：', text);
					uni.showToast({
						title: '复制成功',
					});
				}
			});
		},
		copy2() {
			let text = this.userInfo.userBusinessId

			uni.setClipboardData({
				data: text.toString(),
				success: function (res) {
					console.log('复制的信息2：', text);
					uni.showToast({
						title: '复制成功',
					});
				}
			});
		},
		upload() {

		},
		share() {

		}
	},
	computed: {
		userInfo() {
			return this.userStore.userInfo;
			console.log(this.userStore.userInfo)
		}
	}
}
</script>

<style lang="less" scoped>
.user-info {
	width: 100vw;
	height: 70vh;
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;

	.head {
		display: flex;
		align-items: center;

		.right {
			padding-top: 100rpx;

			text {
				margin-left: 40rpx;
			}

			.num-item {
				display: flex;
				align-items: center;
				color: #aaa;
				font-size: 30rpx;
				margin-top: 20rpx;

				button {
					height: 40rpx;
					line-height: 40rpx;
					margin-left: 20rpx;
					background-color: #048df5;
					color: #fff;
				}
			}
		}
	}

	.code-img {
		width: 550rpx;
		height: 550rpx;
		margin-top: 10rpx;
	}

	.sub-title {
		font-size: 25rpx;
		color: #aaa;
	}

	.share {
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		position: fixed;
		bottom: 0;
		left: 0;

		.share-item {
			display: flex;
			align-items: center;
			flex-direction: column;
			padding: 20rpx;
			width: 50%;

			.share-img {
				width: 65rpx;
				height: 65rpx;
			}

			text {
				margin-top: 20rpx;
			}
		}

	}
}
</style>
